package de.tabuma.shopping.controller;

import de.tabuma.lib.*;
import de.tabuma.shopping.*;
import de.tabuma.shopping.logik.*;
import de.tabuma.shopping.entity.*;
import java.io.*;
import java.util.*;
import java.util.logging.*;
import javax.servlet.*;
import javax.servlet.http.*;
import com.google.appengine.api.users.*;
import de.tabuma.shopping.*;

/**
 * @author $Author: alefen $
 * @version $Revision: 1.2 $
 * @since $Date: 2009/07/21 19:37:32 $
 */
public class description extends tabumacontroller {

    String orderNav;
    private static Logger log =  Logger.getLogger(description.class.getName());
    LicensePackageFacade licensePackageFacade;
    public description(String servlet, Hashtable parameter, String orderNav, LicensePackageFacade licensePackageFacade) {
        super(servlet, parameter);
        this.orderNav = orderNav;
        this.licensePackageFacade = licensePackageFacade;
    }

    public void navigate(ServletContext context, HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
        log.fine("Setting "+this.orderNav+" = "+constants.ORDERNAV_PACKAGE+" in Attribute");
        request.setAttribute(this.orderNav, constants.ORDERNAV_PACKAGE);
        List<LicensePackage> list = licensePackageFacade.getCurrentLicensePackageList();
        request.setAttribute(constants.ORDER_CURRENT_LICENSEPACKAGE_LIST, list);

        UserService userService = UserServiceFactory.getUserService();
        User user = userService.getCurrentUser();

        CurrentOrder currentOrder = CurrentOrderFacade.getCurrentOrder(user.getEmail());
        request.setAttribute(constants.ORDER_CURRENT, currentOrder);

        List<CurrentOrderLicensePackageRelation> colprs = CurrentOrderLicensePackageRelationFacade.getList(currentOrder.getId().intValue());
        request.setAttribute(constants.ORDER_CURRENT_LICENSEPACKAGERELATION_LIST, colprs);
    }
}